//
// Created by xili on 2024/7/31 11:51.
// Go big or go home.
//
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2) {
        int len1 = num1.size();
        int len2 = num2.size();
        int n = max(len1, len2);
        reverse(num1.begin(), num1.end());
        reverse(num2.begin(), num2.end());
        string ans;
        int carry = 0;
        for (int i = 0; i < n; i++) {
            int t1 = i < len1 ? (num1[i] - '0') : 0;
            int t2 = i < len2 ? (num2[i] - '0') : 0;
            ans += to_string((t1 + t2 + carry) % 10);
            carry = (t1 + t2 + carry) / 10;
        }
        ans += carry == 0 ? "" : "1";
        reverse(ans.begin(), ans.end());
        return ans;
    }
};